package Function_Study.comprehensive;

import java.util.ArrayList;
import java.util.Arrays;

public class Test3 {
    public static void main(String[] args) {
        /*
            练习3:
                创建集合添加学生对象,学生对象属性:name,age
                把姓名和年龄拼接成:张三-23的字符串,并放到数组当中(使用方法引用完成)
         */

        ArrayList<Student> students = new ArrayList<>();
        students.add(new Student("雏鹤爱",12));
        students.add(new Student("樱岛麻衣",16));
        students.add(new Student("小鸟游六花",14));
        students.add(new Student("时崎狂三",18));
        students.add(new Student("四糸乃",11));

        String[] list = students.stream().map(Test3::getStr).toArray(String[]::new);
        System.out.println(Arrays.toString(list));
    }

    public static String getStr(Student s){
        return s.getName() + "-" + s.getAge();
    }
}
